package com.authine.cloudpivot.ext.service;

import com.alibaba.cola.dto.SingleResponse;
import com.authine.cloudpivot.ext.dto.kingDee.request.*;
import com.authine.cloudpivot.ext.kingdee.work.InvoiceWork;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;




/**
 * @Author: liwei
 * @DateTime: 2021/7/6
 * @Description: 发票部分生成凭证服务
 */
@Slf4j
public class InvoiceVoucherService {

    private InvoiceWork invoiceService = new InvoiceWork();


    public SingleResponse createInvoiceVoucher( KingDeeInvoiceApply invoiceApply) {
        Assert.notNull(invoiceApply, "开票生成凭证 入参数据为空");

        return invoiceService.createInvoiceVoucher(invoiceApply);
    }

    /* 平台收票生成凭证：/receive/invoice */
    public SingleResponse receiveInvoiceVoucher( KingDeeReceiveInvoice receiveInvoice) {
        Assert.notNull(receiveInvoice, "平台收票生成凭证 入参数据为空");

        return invoiceService.receiveInvoiceVoucher(receiveInvoice);
    }


    /*开红字发票生成凭证：/create/red/invoice*/
    public SingleResponse createRedInvoiceVoucher( KingDeeRedInvoiceApply invoiceApply) {
        Assert.notNull(invoiceApply, "开红字发票生成凭证 入参数据为空");

        return invoiceService.createRedInvoiceVoucher(invoiceApply);
    }


    /*开服务费发票生成凭证：/create/fee/invoice*/
    public SingleResponse createFeeInvoiceVoucher( KingDeeServiceFeeInvoice serviceFeeInvoice) {
        Assert.notNull(serviceFeeInvoice, "开服务费发票生成凭证 入参数据为空");

        return invoiceService.createFeeInvoiceVoucher(serviceFeeInvoice);
    }


    //    开服务费红冲发票生成凭证: /create/fee/red/invoice
    public SingleResponse createFeeRedInvoiceVoucher( KingDeeServiceFeeRedInvoice serviceFeeRedInvoice) {
        Assert.notNull(serviceFeeRedInvoice, "开服务费红冲发票生成凭证 入参数据为空");

        return invoiceService.createFeeRedInvoiceVoucher(serviceFeeRedInvoice);
    }

    // 当前版本未使用   修改发票生成凭证-删除原来的 根据修改时间生成新的: /update/invoice
    public SingleResponse updateInvoiceVoucher( KingDeeUpdateInvoice updateInvoice) {
        Assert.notNull(updateInvoice, "修改发票生成凭证 入参数据为空");

        return invoiceService.updateInvoiceVoucher(updateInvoice);
    }

    //    取消开票删除凭证: /cancel/invoice
    public SingleResponse cancelInvoiceVoucher( String id) {
        Assert.isTrue(StringUtils.isNotBlank(id), "修改发票生成凭证 入参数据为空");

        return invoiceService.cancelInvoiceVoucher(id);
    }

    //    取消确认收票删除凭证: /cancel/receive/invoice
    public SingleResponse cancelReceiveInvoiceVoucher( KingDeeDeleteInvoice deleteInvoice) {
        Assert.notNull(deleteInvoice, "取消确认收票删除凭证 入参数据为空");

        return invoiceService.cancelReceiveInvoiceVoucher(deleteInvoice);
    }

    // 当前版本未使用   平台增补凭证：/create/supplement
    public SingleResponse createSupplementVoucher( KingDeeTrade trade) {
        Assert.notNull(trade, "平台增补凭证 入参数据为空");

        return invoiceService.createSupplementVoucher(trade);
    }



}
